package group2assignone.ucm;

import group2assignone.ucm.administrator.UCAdminLogin;
import group2assignone.ucm.customer.UCCustomerLogin;
import group2assignone.ucm.manager.UCManagerLogin;
import group2assignone.view.MainView;

/**
 * Use Case to select the correct login use case
 * @author group2
 */
public class UCChooseLogin implements UCController {

    private MainView view;
    private String type;

    /**
     * assigns the view
     * @param view
     */
    public UCChooseLogin(MainView view) {
        this.view = view;
    }

    /**
     * Use Case: Select login use case
     * Pre-Condition: Main UI
     * Post-Condition: UI is updated
     * 1. User selects a Login type and presses login
     * 2. System checks login type
     * 3. System loads appropriate login use case
     * 4. (System logs user in and updates UI accordingly)
     */
    public void run() {
        type = view.getType();
        if (type.equals("Administrator")) {
            UCAdminLogin ucal = new UCAdminLogin(view);
            ucal.run();
        } else if (type.equals("Manager")) {
            UCManagerLogin ucml = new UCManagerLogin(view);
            ucml.run();
        } else if (type.equals("General")) {
            UCCustomerLogin uccl = new UCCustomerLogin(view);
            uccl.run();
        }
    }
}
